package question

//970. 强整数
func powerfulIntegers(x int, y int, bound int) []int {
	ans := make([]int, 0)
	m := make(map[int]struct{})
	for i := 1; i < bound; i *= x {
		for j := 1; j < bound; j *= y {
			num := i + j
			if num <= bound {
				m[num] = struct{}{}
			} else {
				break
			}
			if j*y == 1 {
				break
			}
		}
		if i*x == 1 {
			break
		}
	}
	for k := range m {
		ans = append(ans, k)
	}
	return ans
}
